#include "mysql.h"

//获取单行查询结果
//通过查询语句将查询到的单行结果存入传入的字符串数组
int mysql_select_get_one_row(MYSQL *msql,char *state,char (*str_arr)[1024]){

    MYSQL_RES *res = mysql_get_res(msql, state);
    if(res == (MYSQL_RES *)(-1)){
        return -1;
    }

    
    if((mysql_num_rows(res)) != 1){
        return 0;
    }

    int nums = mysql_num_fields(res);
    MYSQL_ROW row = mysql_fetch_row(res);
    for(int i = 0; i < nums; i++){
        strcpy(str_arr[i], row[i]);
    }

    mysql_free_result(res);
    return 1;
}
